(function($){
	$.extend({
		postJSON: function( url, data, callback ) {
			return jQuery.post( url, data, callback, "json" );
		}
	});
	$.doAjaxRet=function(data){
		if(data.statusCode){
			if(data.statusCode==200)
				return true;
			if(data.statusCode==400)
				return false;
			if(data.statusCode==401){
				doBackHome();
				return false;
			}
			if(data.statusCode==500)
				return false;	
		}
		else
			return true;
	};
	$.getSearchValue=function(key){
			var _pathInfo=location.search;
			var start=_pathInfo.indexOf("?"+key+"=");
			if(start==-1){
				 start=_pathInfo.indexOf("&"+key+"=");	
			}
			var end=_pathInfo.indexOf("&");
			if(start>-1){
				if(end==-1)
					end=_pathInfo.length;
				return _pathInfo.substring(start+key.length+2,end).trim();
			}
			else
				return null;	
	};
	$.checkResponse=function(res){
			try{
				var data=JSON.parse(res.responseText);
				if(!$.doAjaxRet(data)){
					$.messager.alert("error",data.message);
					return false;	
				}
			}catch(e){
				//error
			}
			return true;
	};
	$.doLogin=function(){
			$.getJSON("/common/checkoapticket");
	};
	$.startInterval=function(){
			$.loginInter=window.setInterval($.doLogin,5*60*1000);
	};
	$.clearInter=function(){
			window.clearInterval($.loginInter);
	};
	function doBackHome(){
		top.location.href= "/user/logout";
	};
})(jQuery);